POV-Ray : Newsgroups : povray.general : possible #switch error : possible #switch error Server Time
30 Jul 2024 04:23:06 EDT (-0400)
  possible #switch error  
From: Brickman Brick
Date: 11 Nov 2009 07:44:27
Message: <4afab1ab@news.povray.org>
Hello,

I stumbled on some possible strange behaviour in the switch statement. I 
just want to verify if I am doing something wrong or POV-Ray.

The switch statement is placed inside a loop to calculate a value of a 
variable many times.
Here is a short example of the code I wrote. I omitted the necessary 
#break statements for readability.

#switch (MySwitchValue)
	#case (1) //do something
	#case (2) //do something else
	#case (3) //etc1
	#case (0) //etc2
	#else
#end

Now this code works perfectly fine most of the time. Only sometimes it 
breaks and it seems that a #case (1) statement is just partly executed. 
After that, it continues just as expected.

Now when I do the following the code works again as expected.

#switch (MySwitchValue)
	#debug "MyMessage"
	#case (1) //do something
	#case (2) //do something else
	#case (3) //etc1
	#case (0) //etc2
	#else
#end

Moving the #case (0) right in front of #case (1) also works.
This case gives me the impression that the order seems important. On the  
other hand the example with the #debug statement indicates the opposite. 
Also, the docs say I may put the clauses in any order I want.

Does anyone know more about this?
Thanks in advance,

Brickman Brick

-- 
brickcentral.livejournal.com


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.